OpenStack Grizzly - Run Instance
2013/08/13 |
Create and Run Virtual Machine Instance.
|
|
[1] | Create a network which instances use in OpenStack internal system.. |
# nova-manage network create --label (any name) --dns1 (DNS server) --fixed_range_v4=(internal range) [root@dlp ~(keystone)]# nova-manage network create --label network01 --dns1 10.0.0.10 --fixed_range_v4=10.1.0.0/24 [root@dlp ~(keystone)]# nova-manage network list id IPv4 IPv6 start address DNS1 DNS2 VlanID project uuid 4 10.1.0.0/24 None 10.1.0.2 10.0.0.10 None None None fd211350-9f3b-4717-8319-984d624096ba |
[2] | Change default security rules to access to instances with SSH. |
# permit SSH [root@dlp ~(keystone)]# nova secgroup-add-rule default tcp 22 22 0.0.0.0/0 +-------------+-----------+---------+-----------+--------------+ | IP Protocol | From Port | To Port | IP Range | Source Group | +-------------+-----------+---------+-----------+--------------+ | tcp | 22 | 22 | 0.0.0.0/0 | | +-------------+-----------+---------+-----------+--------------+ # permit ICMP [root@dlp ~(keystone)]# nova secgroup-add-rule default icmp -1 -1 0.0.0.0/0 +-------------+-----------+---------+-----------+--------------+ | IP Protocol | From Port | To Port | IP Range | Source Group | +-------------+-----------+---------+-----------+--------------+ | icmp | -1 | -1 | 0.0.0.0/0 | | +-------------+-----------+---------+-----------+--------------+[root@dlp ~(keystone)]# nova secgroup-list-rules default +-------------+-----------+---------+-----------+--------------+ | IP Protocol | From Port | To Port | IP Range | Source Group | +-------------+-----------+---------+-----------+--------------+ | icmp | -1 | -1 | 0.0.0.0/0 | | | tcp | 22 | 22 | 0.0.0.0/0 | | +-------------+-----------+---------+-----------+--------------+ |
[3] | Specify flavor (memory or disk) and create an instance and boot it. |
# default flavor list [root@dlp ~(keystone)]# nova flavor-list +----+-----------+-----------+------+-----------+------+-------+-------------+-----------+-------------+ | ID | Name | Memory_MB | Disk | Ephemeral | Swap | VCPUs | RXTX_Factor | Is_Public | extra_specs | +----+-----------+-----------+------+-----------+------+-------+-------------+-----------+-------------+ | 1 | m1.tiny | 512 | 0 | 0 | | 1 | 1.0 | True | {} | | 2 | m1.small | 2048 | 20 | 0 | | 1 | 1.0 | True | {} | | 3 | m1.medium | 4096 | 40 | 0 | | 2 | 1.0 | True | {} | | 4 | m1.large | 8192 | 80 | 0 | | 4 | 1.0 | True | {} | | 5 | m1.xlarge | 16384 | 160 | 0 | | 8 | 1.0 | True | {} | +----+-----------+-----------+------+-----------+------+-------+-------------+-----------+-------------+ # confirm virtual image [root@dlp ~(keystone)]# nova image-list +--------------------------------------+---------+--------+--------+ | ID | Name | Status | Server | +--------------------------------------+---------+--------+--------+ | d41846d5-c67c-49f2-a616-6c9a136bed3a | CentOS6 | ACTIVE | | +--------------------------------------+---------+--------+--------+ # create and boot an instance [root@dlp ~(keystone)]# nova boot --flavor 2 --image d41846d5-c67c-49f2-a616-6c9a136bed3a --security_group default CentOS6 +-------------------------------------+--------------------------------------+ | Property | Value | +-------------------------------------+--------------------------------------+ | OS-EXT-STS:task_state | scheduling | | image | CentOS6 | | OS-EXT-STS:vm_state | building | | OS-EXT-SRV-ATTR:instance_name | instance-00000003 | | flavor | m1.small | | id | 6d2251b2-2092-445e-a71d-1c43b0b8881e | | security_groups | [{u'name': u'default'}] | | user_id | 5137a165952b4793a9b0ec0779d7472c | | OS-DCF:diskConfig | MANUAL | | accessIPv4 | | | accessIPv6 | | | progress | 0 | | OS-EXT-STS:power_state | 0 | | OS-EXT-AZ:availability_zone | nova | | config_drive | | | status | BUILD | | updated | 2013-08-13T04:55:25Z | | hostId | | | OS-EXT-SRV-ATTR:host | None | | key_name | None | | OS-EXT-SRV-ATTR:hypervisor_hostname | None | | name | CentOS6 | | adminPass | bUKym3bhfRtC | | tenant_id | 4fc0e91962e24923bfe50db73d6930ef | | created | 2013-08-13T04:55:25Z | | metadata | {} | +-------------------------------------+--------------------------------------+ # confirm status [root@dlp ~(keystone)]# nova list +--------------------------------------+---------+--------+--------------------+ | ID | Name | Status | Networks | +--------------------------------------+---------+--------+--------------------+ | a610d03b-89cb-4ae2-86ce-5f6564f533a2 | CentOS6 | BUILD | network01=10.1.0.3 | +--------------------------------------+---------+--------+--------------------+ |
[4] | Login to the Instance just booted. |
# after few minutes later, the Status turns "ACTIVE" like follows [root@dlp ~(keystone)]# nova list +--------------------------------------+---------+--------+--------------------+ | ID | Name | Status | Networks | +--------------------------------------+---------+--------+--------------------+ | a610d03b-89cb-4ae2-86ce-5f6564f533a2 | CentOS6 | ACTIVE | network01=10.1.0.3 | +--------------------------------------+---------+--------+--------------------+ # it's OK if answer replys like follows [root@dlp ~(keystone)]# ping 10.1.0.3 PING 10.1.0.3 (10.1.0.3) 56(84) bytes of data. 64 bytes from 10.1.0.3: icmp_seq=1 ttl=64 time=0.465 ms 64 bytes from 10.1.0.3: icmp_seq=2 ttl=64 time=0.336 ms --- 10.1.0.3 ping statistics --- 2 packets transmitted, 2 received, 0% packet loss, time 1009ms rtt min/avg/max/mdev = 0.336/0.400/0.465/0.067 ms # login with SSH [root@dlp ~(keystone)]# ssh 10.1.0.3 The authenticity of host '10.1.0.3 (10.1.0.3)' can't be established. RSA key fingerprint is 93:42:6b:a4:c2:46:45:a0:17:74:25:53:9c:35:08:a2. Are you sure you want to continue connecting (yes/no)? yes Warning: Permanently added '10.1.0.3' (RSA) to the list of known hosts. root@10.1.0.3's password: # the root password you set during virtual machine installation Last login: Tue Aug 13 04:30:37 2013 [root@centos6 ~]# # just logined normally |
[5] | If you'd like to stop an instance, it's possible to shutdown in instance with shutdown command off course, but it's also possible to control with nova command like follows. |
[root@dlp ~(keystone)]# nova list +--------------------------------------+---------+--------+--------------------+ | ID | Name | Status | Networks | +--------------------------------------+---------+--------+--------------------+ | a610d03b-89cb-4ae2-86ce-5f6564f533a2 | CentOS6 | ACTIVE | network01=10.1.0.3 | +--------------------------------------+---------+--------+--------------------+ # stop instance [root@dlp ~(keystone)]# nova stop a610d03b-89cb-4ae2-86ce-5f6564f533a2 [root@dlp ~(keystone)]# nova list +--------------------------------------+---------+---------+--------------------+ | ID | Name | Status | Networks | +--------------------------------------+---------+---------+--------------------+ | a610d03b-89cb-4ae2-86ce-5f6564f533a2 | CentOS6 | SHUTOFF | network01=10.1.0.3 | +--------------------------------------+---------+---------+--------------------+ # start instance again [root@dlp ~(keystone)]# nova start a610d03b-89cb-4ae2-86ce-5f6564f533a2 [root@dlp ~(keystone)]# nova list +--------------------------------------+---------+--------+--------------------+ | ID | Name | Status | Networks | +--------------------------------------+---------+--------+--------------------+ | a610d03b-89cb-4ae2-86ce-5f6564f533a2 | CentOS6 | ACTIVE | network01=10.1.0.3 | +--------------------------------------+---------+--------+--------------------+ |